package com.ncase.web.controller.auto;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ncase.common.annotation.Log;
import com.ncase.common.core.controller.BaseController;
import com.ncase.common.core.domain.AjaxResult;
import com.ncase.common.enums.BusinessType;
import com.ncase.auto.domain.NcaseApiGroup;
import com.ncase.auto.service.INcaseApiGroupService;
import com.ncase.common.utils.poi.ExcelUtil;
import com.ncase.common.core.page.TableDataInfo;

/**
 * 接口分组Controller
 * 
 * @author zouhuu
 * @date 2025-06-02
 */
@RestController
@RequestMapping("/auto/ncaseApiGroup")
public class NcaseApiGroupController extends BaseController
{
    @Autowired
    private INcaseApiGroupService ncaseApiGroupService;

    /**
     * 查询接口分组列表
     */
    @PreAuthorize("@ss.hasPermi('auto:ncaseApiGroup:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcaseApiGroup ncaseApiGroup)
    {
        startPage();
        List<NcaseApiGroup> list = ncaseApiGroupService.selectNcaseApiGroupList(ncaseApiGroup);
        return getDataTable(list);
    }

    /**
     * 导出接口分组列表
     */
    @PreAuthorize("@ss.hasPermi('auto:ncaseApiGroup:export')")
    @Log(title = "接口分组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcaseApiGroup ncaseApiGroup)
    {
        List<NcaseApiGroup> list = ncaseApiGroupService.selectNcaseApiGroupList(ncaseApiGroup);
        ExcelUtil<NcaseApiGroup> util = new ExcelUtil<NcaseApiGroup>(NcaseApiGroup.class);
        util.exportExcel(response, list, "接口分组数据");
    }

    /**
     * 获取接口分组详细信息
     */
    @PreAuthorize("@ss.hasPermi('auto:ncaseApiGroup:query')")
    @GetMapping(value = "/{groupId}")
    public AjaxResult getInfo(@PathVariable("groupId") Long groupId)
    {
        return success(ncaseApiGroupService.selectNcaseApiGroupByGroupId(groupId));
    }

    /**
     * 新增接口分组
     */
    @PreAuthorize("@ss.hasPermi('auto:ncaseApiGroup:add')")
    @Log(title = "接口分组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcaseApiGroup ncaseApiGroup)
    {
        return toAjax(ncaseApiGroupService.insertNcaseApiGroup(ncaseApiGroup));
    }

    /**
     * 修改接口分组
     */
    @PreAuthorize("@ss.hasPermi('auto:ncaseApiGroup:edit')")
    @Log(title = "接口分组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcaseApiGroup ncaseApiGroup)
    {
        return toAjax(ncaseApiGroupService.updateNcaseApiGroup(ncaseApiGroup));
    }

    /**
     * 删除接口分组
     */
    @PreAuthorize("@ss.hasPermi('auto:ncaseApiGroup:remove')")
    @Log(title = "接口分组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{groupIds}")
    public AjaxResult remove(@PathVariable Long[] groupIds)
    {
        return toAjax(ncaseApiGroupService.deleteNcaseApiGroupByGroupIds(groupIds));
    }
}
